<template>
    <div class="tab-bar">
        <div v-for="(tab, index) in tabs" :key="index" :class="['tab-item', { active: activeTab === index }]"
            @click="changeTab(index)">
            <div class="bottom">
                <div><van-icon class="bottom-iconfont" :name="tab.icon" /></div>
                {{ tab.label }}
            </div>
            
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const tabs = [
    { label: '首页', path: '/' , icon:"wap-home-o"},
    { label: '看板', path: '/dashboard' , icon:"tv-o"},
    { label: '其他', path: '/others' , icon:"manager-o"},
];

const activeTab = ref(0);

const changeTab = (index: number) => {
    activeTab.value = index;
    navigateTo(tabs[index].path);
};
</script>

<style scoped>
.tab-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: #f7f7f7;
    border-top: 1px solid #e0e0e0;
    font-size: 12px;

    .bottom{
        /* flex-direction: column; */
        text-align: center;
        .bottom-iconfont{
            font-size: 20px;
        }
    }
}

.tab-item {
    padding: 10px;
    cursor: pointer;
    
}

.tab-item.active {
    color: #0768f9;
    font-weight: bold;
}
</style>